/**
 * Bestpay.com.cn Inc.
 * Copyright (c) 2011-2017 All Rights Reserved.
 */
package com.sgzn.sgpay.model.response;

import com.sgzn.sgpay.enums.SgsResponseCode;
import lombok.Data;
import lombok.ToString;

import java.util.HashMap;
import java.util.Map;

/**
 * 响应码转换结果，result-是否保存原响应的result
 * @author zhongzhongyong
 * @version Id: ConvertCodeResponse.java, v 0.1 2018/4/3 23:35 zhongzhongyong Exp $$
 */
@Data
@ToString(callSuper = true)
public class ConvertCodeResponse extends CommonResponse<Boolean> {

    /**
     * 请求成功标识
     */
    private boolean success;

    /**
     * 额外的返回参数(用于web层返回给商户)
     */
    private Map<String, String> extraParameters;

    public ConvertCodeResponse() {
        extraParameters = new HashMap<>();
    }

    public ConvertCodeResponse(String errorCode, String errorMsg) {
        this();
        setErrorCode(errorCode);
        setErrorMsg(errorMsg);
        setSuccess(SgsResponseCode.C200.getResponseCode().equals(errorCode));
        setResult(this.isSuccess());
    }

    /**
     * 设置错误编码信息
     * @param responseCode
     */
    public void setResponseCode(SgsResponseCode responseCode) {
        setErrorCode(responseCode.getResponseCode());
        setErrorMsg(responseCode.getResponseDesc());
    }
}
